var flexApp;

FABridge.addInitializationCallback( "googleWeatherWidget", function() {
	flexApp = FABridge.googleWeatherWidget.root();
	var callback = function() {
		var url = 'http://pipes.yahoo.com/pipes/pipe.run?'
        url += '&_id=eBxyJgZh3RGQLC8B6icw5g';
        url += '&_render=json';
        url += '&location=incheon';
        url += '&_callback=callFlexResult';
        url += '&' + Math.round(Math.random()* (new Date().getTime()));
        
        if ($('weatherInfo')) {
            $('weatherInfo').remove();    
        }
        var weatherInfo = new Element('script',{
            id: 'weatherInfo',
            type: 'text/javascript',
               src: url});
        $$('head')[0].insert(weatherInfo);
	}
	flexApp.getTimer().addEventListener("timer", callback);
	callback();
});

function callFlexResult(data) {
	flexApp.callFlexResult(data);
}
